import { createMemoryHistory, createRouter } from 'vue-router'

// import NProgress from 'nprogress'
// import 'nprogress/nprogress.css'

const routes = [
  { path: '/', redirect: '/home' },
  {
    path: '/home',
    component: () => import('@/Views/HomeView.vue'),
    meta: { title: '首页' },
  },
  {
    path: '/menu',
    component: () => import('./Views/MenuView.vue'),
    redirect: '/game',
    meta: { title: '菜单页' },
    children: [
      {
        path: '/game',
        component: () => import('@/Views/GameView.vue'),
        meta: { title: '游戏页' },
      },
      {
        path: '/movie',
        component: () => import('@/Views/MovieView.vue'),
        meta: { title: '电影页' },
      },
    ],
  },
]

const router = createRouter({
  history: createMemoryHistory(),
  routes,
})

// NProgress.configure({ showSpinner: false })

router.beforeEach((to, from) => {
  // NProgress.start()
  document.title = to.meta.title
})

router.afterEach((to, from) => {
  // NProgress.done()
})

export default router
